package edu.sctu;


import edu.sctu.util.DBUtil;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

public class Login extends HttpServlet{

    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {

        //账号密码验证
        String username = req.getParameter("username");
        String password = req.getParameter("password");
        User user = new User();
        user.setName(username);
        user.setPassword(password);
        if (DBUtil.toLoginFor(user)) {
            req.setAttribute("list",DBUtil.query(user));
            req.getRequestDispatcher("/userList.jsp").forward(req, resp);
        }
        else {
            req.getRequestDispatcher("/login.jsp").forward(req, resp);
        }

        }



}




